<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // [js] 去除字符串中最后一个指定的字符
    function delLast(str, params) {
      let index = str.lastIndexOf(params)
      return str.substring(0,index) + str.substring(index+1,str.length)
    }
    const str = delLast('asdfghhj', 'h')
    console.log(str);
    function del(str, params) {
      let index = str.lastIndexOf(params)
      if (index > -1) {
        let arr = [...str]
        arr.splice(index,1)
        return arr.join('')
      }
    }
    let str1 = del('asdfghhj', 'h')
    console.log(str1);
  </script>
</body>
</html>